<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改消息通知')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-notify-edit" th:object="${notify}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">关联消息类型：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input name="messageType" id="messageType" type="hidden" th:value="*{messageType}">
                    <input name="messageTypeName" onclick="selectTypeTree()" id="messageTypeName" type="text"
                           th:value="*{messageTypeName}" class="form-control" readonly>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">通知名称：</label>
            <div class="col-sm-8">
                <input name="notifyName" class="form-control" type="text" th:value="*{notifyName}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">通知标识：</label>
            <div class="col-sm-8">
                <input name="identify" class="form-control" type="text" th:value="*{identify}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">通知说明：</label>
            <div class="col-sm-8">
                <input name="about" class="form-control" type="text" th:value="*{about}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">通知状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('custom_normal_disable')}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    <input type="radio" th:id="${dict.dictCode}" name="isEnable" th:value="${dict.dictValue}"
                           th:checked="${dict.default}" th:field="*{isEnable}">
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "back/message/notify";


    // 选择消息分类树
    function selectTypeTree() {
        var typeId = $("#messageType").val();
        var typeId = $.common.isEmpty(typeId) ? "100" : $("#messageType").val();
        var url = ctx + "back/message/type/selectTypeTree/" + typeId;
        var options = {
            title: '选择消息分类',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#messageType").val(body.find('#treeId').val());
            $("#messageTypeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }

    $("#form-notify-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-notify-edit').serialize());
        }
    }

</script>
</body>
</html>